package bao;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class Addck
 */
@WebServlet("/Addck")
public class Addck extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public Addck() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		try {request.setCharacterEncoding("UTF-8");
		response.setContentType("text/html;charset=UTF-8");
		Class.forName("com.mysql.cj.jdbc.Driver");
		Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/yj?autoReconnect=true&serverTimezone=GMT","root","root");
		PreparedStatement j=con.prepareStatement("insert into ck(qyid,site_w,site_j)value(?,?,?)");
		j.setString(1, request.getParameter("qyid"));
		j.setString(2, request.getParameter("site_w"));
		j.setString(3, request.getParameter("site_j"));
		j.executeUpdate();
		
		
			


j.close();
		con.close();
		response.sendRedirect("start.jsp");
				

		}catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
